﻿namespace EyeOpen.Windows.Form
{
	using System.Text;
	using System.Windows.Forms;

	public static class ControlExtensions
	{
		public static string GetHierarchicalId(this Control control)
		{
			const char Separator = '.';

			var current = control;

			var stringBuilder = new StringBuilder();

			while (current != null)
			{
				stringBuilder.Insert(0, current.Name + Separator);
				current = current.Parent;
			}

			return stringBuilder.ToString().TrimEnd(Separator);
		}
	}
}